package tank.po;

import tank.util.Audio;
import tank.util.ResourceMgr;

import java.awt.*;

public class Explode {
    //定义爆炸的位置
    private int x, y;
    //根据图片大小确定爆炸大小
    public static final int WIDTH = ResourceMgr.explodes[0].getWidth();
    public static final int HEIGHT = ResourceMgr.explodes[0].getHeight();
    //坦克拿到子弹的引用
    public TankFrame tf;
    //判断坦克是否存活
    public boolean living = true;
    public int step = 0;
    //构造器
    public Explode(int x, int y,  TankFrame tf) {
        this.x = x;
        this.y = y;
        this.tf = tf;

        new Thread(()->new Audio("audio/explode.wav").play()).start();
    }

    //画爆炸 加爆炸移除
    public void paint(Graphics g) {
        g.drawImage(ResourceMgr.explodes[step++],x,y,null);
        if (step >= ResourceMgr.explodes.length){
            step = 0;
            tf.explodes.remove(this);
        }
    }
}


